import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '@/views/login/index'
import Home from '@/views/home/index'
import Welcome from '@/views/home/welcome'
import User from '@/views/user/index.vue'
import Stu from '@/views/stu/index.vue'
import Admin from '@/views/admin/index.vue'
import GoodsType from '@/views/goodsType/index.vue'
import LayoutMenu from '@/views/layoutMenu/index.vue'
import LayoutCarousel from '@/views/layoutCarousel/index.vue'
import Goods from '@/views/goods/index.vue'
import GoodsAdd from '@/views/goods/goodsAdd.vue'
import GoodsBrank from '@/views/goodsBrank/index.vue'
// import store from '@/store'
Vue.use(VueRouter)

const router = new VueRouter({
  // mode: 'history',
  // base: process.env.BASE_URL,
  routes: [
    { path: '/', redirect: '/login' },
    { path: '/login', component: Login },
    {
      path: '/home',
      component: Home,
      redirect: '/welcome',
      children: [
        { path: '/welcome', component: Welcome },
        { path: '/user', component: User },
        { path: '/stu', component: Stu },
        { path: '/admin', component: Admin },
        { path: '/goodsType', component: GoodsType },
        { path: '/layoutMenu', component: LayoutMenu },
        { path: '/layoutCarousel', component: LayoutCarousel },
        { path: '/goods', component: Goods },
        { path: '/goodsAdd', component: GoodsAdd },
        { path: '/goodsBrank', component: GoodsBrank }
      ]
    }
  ]
})
// const router = new VueRouter({
//   mode: 'hash',
//   base: process.env.BASE_URL,
//   routes

// router.beforeEach((to, from, next) => {
//   const token = store.getters.token
//   if (token) {
//     next()
//   } else {
//     next('/login')
//   }
// })

export default router
